/*
 * Selling Partner API for Messaging
 * With the Messaging API you can build applications that send messages to buyers. You can get a list of message types that are available for an order that you specify, then call an operation that sends a message to the buyer for that order. The Messaging API returns responses that are formed according to the <a href=https://tools.ietf.org/html/draft-kelly-json-hal-08>JSON Hypertext Application Language</a> (HAL) standard.
 *
 * OpenAPI spec version: v1
 *
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */

package software.amazon.spapi.api.messaging.v1;

import com.amazon.SellingPartnerAPIAA.LWAAccessTokenCache;
import com.amazon.SellingPartnerAPIAA.LWAAccessTokenCacheImpl;
import com.amazon.SellingPartnerAPIAA.LWAAuthorizationCredentials;
import com.amazon.SellingPartnerAPIAA.LWAAuthorizationSigner;
import com.amazon.SellingPartnerAPIAA.LWAException;
import com.amazon.SellingPartnerAPIAA.RestrictedDataTokenSigner;
import com.google.gson.reflect.TypeToken;
import io.github.bucket4j.Bucket;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.spapi.ApiCallback;
import software.amazon.spapi.ApiClient;
import software.amazon.spapi.ApiException;
import software.amazon.spapi.ApiResponse;
import software.amazon.spapi.Configuration;
import software.amazon.spapi.Pair;
import software.amazon.spapi.ProgressRequestBody;
import software.amazon.spapi.StringUtil;
import software.amazon.spapi.models.messaging.v1.CreateAmazonMotorsRequest;
import software.amazon.spapi.models.messaging.v1.CreateAmazonMotorsResponse;
import software.amazon.spapi.models.messaging.v1.CreateConfirmCustomizationDetailsRequest;
import software.amazon.spapi.models.messaging.v1.CreateConfirmCustomizationDetailsResponse;
import software.amazon.spapi.models.messaging.v1.CreateConfirmDeliveryDetailsRequest;
import software.amazon.spapi.models.messaging.v1.CreateConfirmDeliveryDetailsResponse;
import software.amazon.spapi.models.messaging.v1.CreateConfirmOrderDetailsRequest;
import software.amazon.spapi.models.messaging.v1.CreateConfirmOrderDetailsResponse;
import software.amazon.spapi.models.messaging.v1.CreateConfirmServiceDetailsRequest;
import software.amazon.spapi.models.messaging.v1.CreateConfirmServiceDetailsResponse;
import software.amazon.spapi.models.messaging.v1.CreateDigitalAccessKeyRequest;
import software.amazon.spapi.models.messaging.v1.CreateDigitalAccessKeyResponse;
import software.amazon.spapi.models.messaging.v1.CreateLegalDisclosureRequest;
import software.amazon.spapi.models.messaging.v1.CreateLegalDisclosureResponse;
import software.amazon.spapi.models.messaging.v1.CreateUnexpectedProblemRequest;
import software.amazon.spapi.models.messaging.v1.CreateUnexpectedProblemResponse;
import software.amazon.spapi.models.messaging.v1.CreateWarrantyRequest;
import software.amazon.spapi.models.messaging.v1.CreateWarrantyResponse;
import software.amazon.spapi.models.messaging.v1.GetAttributesResponse;
import software.amazon.spapi.models.messaging.v1.GetMessagingActionsForOrderResponse;
import software.amazon.spapi.models.messaging.v1.InvoiceRequest;
import software.amazon.spapi.models.messaging.v1.InvoiceResponse;

public class MessagingApi {
    private ApiClient apiClient;
    private Boolean disableRateLimiting;

    public MessagingApi(ApiClient apiClient, Boolean disableRateLimiting) {
        this.apiClient = apiClient;
        this.disableRateLimiting = disableRateLimiting;
    }

    private final Configuration config = Configuration.get();

    public final Bucket confirmCustomizationDetailsBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-confirmCustomizationDetails"))
            .build();

    public final Bucket createAmazonMotorsBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-createAmazonMotors"))
            .build();

    public final Bucket createConfirmDeliveryDetailsBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-createConfirmDeliveryDetails"))
            .build();

    public final Bucket createConfirmOrderDetailsBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-createConfirmOrderDetails"))
            .build();

    public final Bucket createConfirmServiceDetailsBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-createConfirmServiceDetails"))
            .build();

    public final Bucket createDigitalAccessKeyBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-createDigitalAccessKey"))
            .build();

    public final Bucket createLegalDisclosureBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-createLegalDisclosure"))
            .build();

    public final Bucket createUnexpectedProblemBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-createUnexpectedProblem"))
            .build();

    public final Bucket createWarrantyBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-createWarranty"))
            .build();

    public final Bucket getAttributesBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-getAttributes"))
            .build();

    public final Bucket getMessagingActionsForOrderBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-getMessagingActionsForOrder"))
            .build();

    public final Bucket sendInvoiceBucket = Bucket.builder()
            .addLimit(config.getLimit("MessagingApi-sendInvoice"))
            .build();

    /**
     * Build call for confirmCustomizationDetails
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call confirmCustomizationDetailsCall(
            CreateConfirmCustomizationDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/messages/confirmCustomizationDetails"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call confirmCustomizationDetailsValidateBeforeCall(
            CreateConfirmCustomizationDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException(
                    "Missing the required parameter 'body' when calling confirmCustomizationDetails(Async)");
        }
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling confirmCustomizationDetails(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling confirmCustomizationDetails(Async)");
        }

        return confirmCustomizationDetailsCall(body, amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a message asking a buyer to provide or verify customization details such as name spelling, images,
     * initials, etc. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return CreateConfirmCustomizationDetailsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateConfirmCustomizationDetailsResponse confirmCustomizationDetails(
            CreateConfirmCustomizationDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<CreateConfirmCustomizationDetailsResponse> resp =
                confirmCustomizationDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a message asking a buyer to provide or verify customization details such as name spelling, images,
     * initials, etc. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return CreateConfirmCustomizationDetailsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateConfirmCustomizationDetailsResponse confirmCustomizationDetails(
            CreateConfirmCustomizationDetailsRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<CreateConfirmCustomizationDetailsResponse> resp =
                confirmCustomizationDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a message asking a buyer to provide or verify customization details such as name spelling, images,
     * initials, etc. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;CreateConfirmCustomizationDetailsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateConfirmCustomizationDetailsResponse> confirmCustomizationDetailsWithHttpInfo(
            CreateConfirmCustomizationDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = confirmCustomizationDetailsValidateBeforeCall(body, amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-confirmCustomizationDetails");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || confirmCustomizationDetailsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateConfirmCustomizationDetailsResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("confirmCustomizationDetails operation exceeds rate limit");
    }

    /**
     * Sends a message asking a buyer to provide or verify customization details such as name spelling, images,
     * initials, etc. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;CreateConfirmCustomizationDetailsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateConfirmCustomizationDetailsResponse> confirmCustomizationDetailsWithHttpInfo(
            CreateConfirmCustomizationDetailsRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        return confirmCustomizationDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a message asking a buyer to provide or verify customization details such as name spelling,
     * images, initials, etc. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call confirmCustomizationDetailsAsync(
            CreateConfirmCustomizationDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateConfirmCustomizationDetailsResponse> callback)
            throws ApiException, LWAException {
        return confirmCustomizationDetailsAsync(body, amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a message asking a buyer to provide or verify customization details such as name spelling,
     * images, initials, etc. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call confirmCustomizationDetailsAsync(
            CreateConfirmCustomizationDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateConfirmCustomizationDetailsResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = confirmCustomizationDetailsValidateBeforeCall(
                body, amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-confirmCustomizationDetails");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || confirmCustomizationDetailsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateConfirmCustomizationDetailsResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("confirmCustomizationDetails operation exceeds rate limit");
    }
    /**
     * Build call for createAmazonMotors
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call createAmazonMotorsCall(
            CreateAmazonMotorsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/messages/amazonMotors"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call createAmazonMotorsValidateBeforeCall(
            CreateAmazonMotorsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException("Missing the required parameter 'body' when calling createAmazonMotors(Async)");
        }
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling createAmazonMotors(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling createAmazonMotors(Async)");
        }

        return createAmazonMotorsCall(body, amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a message to a buyer to provide details about an Amazon Motors order. This message can only be sent by
     * Amazon Motors sellers. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return CreateAmazonMotorsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateAmazonMotorsResponse createAmazonMotors(
            CreateAmazonMotorsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<CreateAmazonMotorsResponse> resp =
                createAmazonMotorsWithHttpInfo(body, amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a message to a buyer to provide details about an Amazon Motors order. This message can only be sent by
     * Amazon Motors sellers. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return CreateAmazonMotorsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateAmazonMotorsResponse createAmazonMotors(
            CreateAmazonMotorsRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<CreateAmazonMotorsResponse> resp =
                createAmazonMotorsWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a message to a buyer to provide details about an Amazon Motors order. This message can only be sent by
     * Amazon Motors sellers. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;CreateAmazonMotorsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateAmazonMotorsResponse> createAmazonMotorsWithHttpInfo(
            CreateAmazonMotorsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = createAmazonMotorsValidateBeforeCall(body, amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-createAmazonMotors");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createAmazonMotorsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateAmazonMotorsResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("createAmazonMotors operation exceeds rate limit");
    }

    /**
     * Sends a message to a buyer to provide details about an Amazon Motors order. This message can only be sent by
     * Amazon Motors sellers. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;CreateAmazonMotorsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateAmazonMotorsResponse> createAmazonMotorsWithHttpInfo(
            CreateAmazonMotorsRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        return createAmazonMotorsWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a message to a buyer to provide details about an Amazon Motors order. This message can
     * only be sent by Amazon Motors sellers. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1
     * | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the
     * operation, when available. The preceding table contains the default rate and burst values for this operation.
     * Selling partners whose business demands require higher throughput might have higher rate and burst values than
     * those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createAmazonMotorsAsync(
            CreateAmazonMotorsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateAmazonMotorsResponse> callback)
            throws ApiException, LWAException {
        return createAmazonMotorsAsync(body, amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a message to a buyer to provide details about an Amazon Motors order. This message can
     * only be sent by Amazon Motors sellers. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1
     * | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the
     * operation, when available. The preceding table contains the default rate and burst values for this operation.
     * Selling partners whose business demands require higher throughput might have higher rate and burst values than
     * those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createAmazonMotorsAsync(
            CreateAmazonMotorsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateAmazonMotorsResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call =
                createAmazonMotorsValidateBeforeCall(body, amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-createAmazonMotors");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createAmazonMotorsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateAmazonMotorsResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("createAmazonMotors operation exceeds rate limit");
    }
    /**
     * Build call for createConfirmDeliveryDetails
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call createConfirmDeliveryDetailsCall(
            CreateConfirmDeliveryDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/messages/confirmDeliveryDetails"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call createConfirmDeliveryDetailsValidateBeforeCall(
            CreateConfirmDeliveryDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException(
                    "Missing the required parameter 'body' when calling createConfirmDeliveryDetails(Async)");
        }
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling createConfirmDeliveryDetails(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling createConfirmDeliveryDetails(Async)");
        }

        return createConfirmDeliveryDetailsCall(body, amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a message to a buyer to arrange a delivery or to confirm contact information for making a delivery. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header contains the usage plan rate limits for the operation, when available. The preceding table
     * contains the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput might have higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return CreateConfirmDeliveryDetailsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateConfirmDeliveryDetailsResponse createConfirmDeliveryDetails(
            CreateConfirmDeliveryDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<CreateConfirmDeliveryDetailsResponse> resp =
                createConfirmDeliveryDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a message to a buyer to arrange a delivery or to confirm contact information for making a delivery. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header contains the usage plan rate limits for the operation, when available. The preceding table
     * contains the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput might have higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return CreateConfirmDeliveryDetailsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateConfirmDeliveryDetailsResponse createConfirmDeliveryDetails(
            CreateConfirmDeliveryDetailsRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<CreateConfirmDeliveryDetailsResponse> resp =
                createConfirmDeliveryDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a message to a buyer to arrange a delivery or to confirm contact information for making a delivery. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header contains the usage plan rate limits for the operation, when available. The preceding table
     * contains the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput might have higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;CreateConfirmDeliveryDetailsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateConfirmDeliveryDetailsResponse> createConfirmDeliveryDetailsWithHttpInfo(
            CreateConfirmDeliveryDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = createConfirmDeliveryDetailsValidateBeforeCall(body, amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-createConfirmDeliveryDetails");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createConfirmDeliveryDetailsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateConfirmDeliveryDetailsResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("createConfirmDeliveryDetails operation exceeds rate limit");
    }

    /**
     * Sends a message to a buyer to arrange a delivery or to confirm contact information for making a delivery. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header contains the usage plan rate limits for the operation, when available. The preceding table
     * contains the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput might have higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;CreateConfirmDeliveryDetailsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateConfirmDeliveryDetailsResponse> createConfirmDeliveryDetailsWithHttpInfo(
            CreateConfirmDeliveryDetailsRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        return createConfirmDeliveryDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a message to a buyer to arrange a delivery or to confirm contact information for making a
     * delivery. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createConfirmDeliveryDetailsAsync(
            CreateConfirmDeliveryDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateConfirmDeliveryDetailsResponse> callback)
            throws ApiException, LWAException {
        return createConfirmDeliveryDetailsAsync(body, amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a message to a buyer to arrange a delivery or to confirm contact information for making a
     * delivery. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createConfirmDeliveryDetailsAsync(
            CreateConfirmDeliveryDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateConfirmDeliveryDetailsResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = createConfirmDeliveryDetailsValidateBeforeCall(
                body, amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-createConfirmDeliveryDetails");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createConfirmDeliveryDetailsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateConfirmDeliveryDetailsResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("createConfirmDeliveryDetails operation exceeds rate limit");
    }
    /**
     * Build call for createConfirmOrderDetails
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call createConfirmOrderDetailsCall(
            CreateConfirmOrderDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/messages/confirmOrderDetails"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call createConfirmOrderDetailsValidateBeforeCall(
            CreateConfirmOrderDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException(
                    "Missing the required parameter 'body' when calling createConfirmOrderDetails(Async)");
        }
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling createConfirmOrderDetails(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling createConfirmOrderDetails(Async)");
        }

        return createConfirmOrderDetailsCall(body, amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a message to ask a buyer an order-related question prior to shipping their order. **Usage Plan:** | Rate
     * (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header
     * contains the usage plan rate limits for the operation, when available. The preceding table contains the default
     * rate and burst values for this operation. Selling partners whose business demands require higher throughput might
     * have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return CreateConfirmOrderDetailsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateConfirmOrderDetailsResponse createConfirmOrderDetails(
            CreateConfirmOrderDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<CreateConfirmOrderDetailsResponse> resp =
                createConfirmOrderDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a message to ask a buyer an order-related question prior to shipping their order. **Usage Plan:** | Rate
     * (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header
     * contains the usage plan rate limits for the operation, when available. The preceding table contains the default
     * rate and burst values for this operation. Selling partners whose business demands require higher throughput might
     * have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return CreateConfirmOrderDetailsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateConfirmOrderDetailsResponse createConfirmOrderDetails(
            CreateConfirmOrderDetailsRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<CreateConfirmOrderDetailsResponse> resp =
                createConfirmOrderDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a message to ask a buyer an order-related question prior to shipping their order. **Usage Plan:** | Rate
     * (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header
     * contains the usage plan rate limits for the operation, when available. The preceding table contains the default
     * rate and burst values for this operation. Selling partners whose business demands require higher throughput might
     * have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;CreateConfirmOrderDetailsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateConfirmOrderDetailsResponse> createConfirmOrderDetailsWithHttpInfo(
            CreateConfirmOrderDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = createConfirmOrderDetailsValidateBeforeCall(body, amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-createConfirmOrderDetails");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createConfirmOrderDetailsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateConfirmOrderDetailsResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("createConfirmOrderDetails operation exceeds rate limit");
    }

    /**
     * Sends a message to ask a buyer an order-related question prior to shipping their order. **Usage Plan:** | Rate
     * (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header
     * contains the usage plan rate limits for the operation, when available. The preceding table contains the default
     * rate and burst values for this operation. Selling partners whose business demands require higher throughput might
     * have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;CreateConfirmOrderDetailsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateConfirmOrderDetailsResponse> createConfirmOrderDetailsWithHttpInfo(
            CreateConfirmOrderDetailsRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        return createConfirmOrderDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a message to ask a buyer an order-related question prior to shipping their order. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header contains the usage plan rate limits for the operation, when available. The preceding table
     * contains the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput might have higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createConfirmOrderDetailsAsync(
            CreateConfirmOrderDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateConfirmOrderDetailsResponse> callback)
            throws ApiException, LWAException {
        return createConfirmOrderDetailsAsync(body, amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a message to ask a buyer an order-related question prior to shipping their order. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header contains the usage plan rate limits for the operation, when available. The preceding table
     * contains the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput might have higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createConfirmOrderDetailsAsync(
            CreateConfirmOrderDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateConfirmOrderDetailsResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = createConfirmOrderDetailsValidateBeforeCall(
                body, amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-createConfirmOrderDetails");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createConfirmOrderDetailsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateConfirmOrderDetailsResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("createConfirmOrderDetails operation exceeds rate limit");
    }
    /**
     * Build call for createConfirmServiceDetails
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call createConfirmServiceDetailsCall(
            CreateConfirmServiceDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/messages/confirmServiceDetails"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call createConfirmServiceDetailsValidateBeforeCall(
            CreateConfirmServiceDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException(
                    "Missing the required parameter 'body' when calling createConfirmServiceDetails(Async)");
        }
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling createConfirmServiceDetails(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling createConfirmServiceDetails(Async)");
        }

        return createConfirmServiceDetailsCall(body, amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a message to contact a Home Service customer to arrange a service call or to gather information prior to a
     * service call. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return CreateConfirmServiceDetailsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateConfirmServiceDetailsResponse createConfirmServiceDetails(
            CreateConfirmServiceDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<CreateConfirmServiceDetailsResponse> resp =
                createConfirmServiceDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a message to contact a Home Service customer to arrange a service call or to gather information prior to a
     * service call. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return CreateConfirmServiceDetailsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateConfirmServiceDetailsResponse createConfirmServiceDetails(
            CreateConfirmServiceDetailsRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<CreateConfirmServiceDetailsResponse> resp =
                createConfirmServiceDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a message to contact a Home Service customer to arrange a service call or to gather information prior to a
     * service call. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;CreateConfirmServiceDetailsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateConfirmServiceDetailsResponse> createConfirmServiceDetailsWithHttpInfo(
            CreateConfirmServiceDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = createConfirmServiceDetailsValidateBeforeCall(body, amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-createConfirmServiceDetails");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createConfirmServiceDetailsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateConfirmServiceDetailsResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("createConfirmServiceDetails operation exceeds rate limit");
    }

    /**
     * Sends a message to contact a Home Service customer to arrange a service call or to gather information prior to a
     * service call. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;CreateConfirmServiceDetailsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateConfirmServiceDetailsResponse> createConfirmServiceDetailsWithHttpInfo(
            CreateConfirmServiceDetailsRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        return createConfirmServiceDetailsWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a message to contact a Home Service customer to arrange a service call or to gather
     * information prior to a service call. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 |
     * 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation,
     * when available. The preceding table contains the default rate and burst values for this operation. Selling
     * partners whose business demands require higher throughput might have higher rate and burst values than those
     * shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createConfirmServiceDetailsAsync(
            CreateConfirmServiceDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateConfirmServiceDetailsResponse> callback)
            throws ApiException, LWAException {
        return createConfirmServiceDetailsAsync(body, amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a message to contact a Home Service customer to arrange a service call or to gather
     * information prior to a service call. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 |
     * 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation,
     * when available. The preceding table contains the default rate and burst values for this operation. Selling
     * partners whose business demands require higher throughput might have higher rate and burst values than those
     * shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createConfirmServiceDetailsAsync(
            CreateConfirmServiceDetailsRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateConfirmServiceDetailsResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = createConfirmServiceDetailsValidateBeforeCall(
                body, amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-createConfirmServiceDetails");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createConfirmServiceDetailsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateConfirmServiceDetailsResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("createConfirmServiceDetails operation exceeds rate limit");
    }
    /**
     * Build call for createDigitalAccessKey
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call createDigitalAccessKeyCall(
            CreateDigitalAccessKeyRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/messages/digitalAccessKey"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call createDigitalAccessKeyValidateBeforeCall(
            CreateDigitalAccessKeyRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException("Missing the required parameter 'body' when calling createDigitalAccessKey(Async)");
        }
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling createDigitalAccessKey(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling createDigitalAccessKey(Async)");
        }

        return createDigitalAccessKeyCall(body, amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a buyer a message to share a digital access key that is required to utilize digital content in their order.
     * **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return CreateDigitalAccessKeyResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateDigitalAccessKeyResponse createDigitalAccessKey(
            CreateDigitalAccessKeyRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<CreateDigitalAccessKeyResponse> resp =
                createDigitalAccessKeyWithHttpInfo(body, amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a buyer a message to share a digital access key that is required to utilize digital content in their order.
     * **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return CreateDigitalAccessKeyResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateDigitalAccessKeyResponse createDigitalAccessKey(
            CreateDigitalAccessKeyRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<CreateDigitalAccessKeyResponse> resp =
                createDigitalAccessKeyWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a buyer a message to share a digital access key that is required to utilize digital content in their order.
     * **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;CreateDigitalAccessKeyResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateDigitalAccessKeyResponse> createDigitalAccessKeyWithHttpInfo(
            CreateDigitalAccessKeyRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = createDigitalAccessKeyValidateBeforeCall(body, amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request =
                    RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-createDigitalAccessKey");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createDigitalAccessKeyBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateDigitalAccessKeyResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("createDigitalAccessKey operation exceeds rate limit");
    }

    /**
     * Sends a buyer a message to share a digital access key that is required to utilize digital content in their order.
     * **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;CreateDigitalAccessKeyResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateDigitalAccessKeyResponse> createDigitalAccessKeyWithHttpInfo(
            CreateDigitalAccessKeyRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        return createDigitalAccessKeyWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a buyer a message to share a digital access key that is required to utilize digital
     * content in their order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createDigitalAccessKeyAsync(
            CreateDigitalAccessKeyRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateDigitalAccessKeyResponse> callback)
            throws ApiException, LWAException {
        return createDigitalAccessKeyAsync(body, amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a buyer a message to share a digital access key that is required to utilize digital
     * content in their order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createDigitalAccessKeyAsync(
            CreateDigitalAccessKeyRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateDigitalAccessKeyResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call =
                createDigitalAccessKeyValidateBeforeCall(body, amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request =
                    RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-createDigitalAccessKey");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createDigitalAccessKeyBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateDigitalAccessKeyResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("createDigitalAccessKey operation exceeds rate limit");
    }
    /**
     * Build call for createLegalDisclosure
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call createLegalDisclosureCall(
            CreateLegalDisclosureRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/messages/legalDisclosure"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call createLegalDisclosureValidateBeforeCall(
            CreateLegalDisclosureRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException("Missing the required parameter 'body' when calling createLegalDisclosure(Async)");
        }
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling createLegalDisclosure(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling createLegalDisclosure(Async)");
        }

        return createLegalDisclosureCall(body, amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a critical message that contains documents that a seller is legally obligated to provide to the buyer. This
     * message should only be used to deliver documents that are required by law. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the
     * usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst
     * values for this operation. Selling partners whose business demands require higher throughput might have higher
     * rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return CreateLegalDisclosureResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateLegalDisclosureResponse createLegalDisclosure(
            CreateLegalDisclosureRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<CreateLegalDisclosureResponse> resp =
                createLegalDisclosureWithHttpInfo(body, amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a critical message that contains documents that a seller is legally obligated to provide to the buyer. This
     * message should only be used to deliver documents that are required by law. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the
     * usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst
     * values for this operation. Selling partners whose business demands require higher throughput might have higher
     * rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return CreateLegalDisclosureResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateLegalDisclosureResponse createLegalDisclosure(
            CreateLegalDisclosureRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<CreateLegalDisclosureResponse> resp =
                createLegalDisclosureWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a critical message that contains documents that a seller is legally obligated to provide to the buyer. This
     * message should only be used to deliver documents that are required by law. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the
     * usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst
     * values for this operation. Selling partners whose business demands require higher throughput might have higher
     * rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;CreateLegalDisclosureResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateLegalDisclosureResponse> createLegalDisclosureWithHttpInfo(
            CreateLegalDisclosureRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = createLegalDisclosureValidateBeforeCall(body, amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request =
                    RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-createLegalDisclosure");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createLegalDisclosureBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateLegalDisclosureResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("createLegalDisclosure operation exceeds rate limit");
    }

    /**
     * Sends a critical message that contains documents that a seller is legally obligated to provide to the buyer. This
     * message should only be used to deliver documents that are required by law. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the
     * usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst
     * values for this operation. Selling partners whose business demands require higher throughput might have higher
     * rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;CreateLegalDisclosureResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateLegalDisclosureResponse> createLegalDisclosureWithHttpInfo(
            CreateLegalDisclosureRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        return createLegalDisclosureWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a critical message that contains documents that a seller is legally obligated to provide
     * to the buyer. This message should only be used to deliver documents that are required by law. **Usage Plan:** |
     * Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response
     * header contains the usage plan rate limits for the operation, when available. The preceding table contains the
     * default rate and burst values for this operation. Selling partners whose business demands require higher
     * throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage
     * Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createLegalDisclosureAsync(
            CreateLegalDisclosureRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateLegalDisclosureResponse> callback)
            throws ApiException, LWAException {
        return createLegalDisclosureAsync(body, amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a critical message that contains documents that a seller is legally obligated to provide
     * to the buyer. This message should only be used to deliver documents that are required by law. **Usage Plan:** |
     * Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response
     * header contains the usage plan rate limits for the operation, when available. The preceding table contains the
     * default rate and burst values for this operation. Selling partners whose business demands require higher
     * throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage
     * Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createLegalDisclosureAsync(
            CreateLegalDisclosureRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateLegalDisclosureResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call =
                createLegalDisclosureValidateBeforeCall(body, amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request =
                    RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-createLegalDisclosure");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createLegalDisclosureBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateLegalDisclosureResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("createLegalDisclosure operation exceeds rate limit");
    }
    /**
     * Build call for createUnexpectedProblem
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call createUnexpectedProblemCall(
            CreateUnexpectedProblemRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/messages/unexpectedProblem"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call createUnexpectedProblemValidateBeforeCall(
            CreateUnexpectedProblemRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException("Missing the required parameter 'body' when calling createUnexpectedProblem(Async)");
        }
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling createUnexpectedProblem(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling createUnexpectedProblem(Async)");
        }

        return createUnexpectedProblemCall(body, amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a critical message to a buyer that an unexpected problem was encountered affecting the completion of the
     * order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return CreateUnexpectedProblemResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateUnexpectedProblemResponse createUnexpectedProblem(
            CreateUnexpectedProblemRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<CreateUnexpectedProblemResponse> resp =
                createUnexpectedProblemWithHttpInfo(body, amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a critical message to a buyer that an unexpected problem was encountered affecting the completion of the
     * order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return CreateUnexpectedProblemResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateUnexpectedProblemResponse createUnexpectedProblem(
            CreateUnexpectedProblemRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<CreateUnexpectedProblemResponse> resp =
                createUnexpectedProblemWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a critical message to a buyer that an unexpected problem was encountered affecting the completion of the
     * order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;CreateUnexpectedProblemResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateUnexpectedProblemResponse> createUnexpectedProblemWithHttpInfo(
            CreateUnexpectedProblemRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = createUnexpectedProblemValidateBeforeCall(body, amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-createUnexpectedProblem");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createUnexpectedProblemBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateUnexpectedProblemResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("createUnexpectedProblem operation exceeds rate limit");
    }

    /**
     * Sends a critical message to a buyer that an unexpected problem was encountered affecting the completion of the
     * order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;CreateUnexpectedProblemResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateUnexpectedProblemResponse> createUnexpectedProblemWithHttpInfo(
            CreateUnexpectedProblemRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        return createUnexpectedProblemWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a critical message to a buyer that an unexpected problem was encountered affecting the
     * completion of the order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createUnexpectedProblemAsync(
            CreateUnexpectedProblemRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateUnexpectedProblemResponse> callback)
            throws ApiException, LWAException {
        return createUnexpectedProblemAsync(body, amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a critical message to a buyer that an unexpected problem was encountered affecting the
     * completion of the order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createUnexpectedProblemAsync(
            CreateUnexpectedProblemRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateUnexpectedProblemResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call =
                createUnexpectedProblemValidateBeforeCall(body, amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-createUnexpectedProblem");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createUnexpectedProblemBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateUnexpectedProblemResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("createUnexpectedProblem operation exceeds rate limit");
    }
    /**
     * Build call for createWarranty
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call createWarrantyCall(
            CreateWarrantyRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/messages/warranty"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call createWarrantyValidateBeforeCall(
            CreateWarrantyRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException("Missing the required parameter 'body' when calling createWarranty(Async)");
        }
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException("Missing the required parameter 'amazonOrderId' when calling createWarranty(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling createWarranty(Async)");
        }

        return createWarrantyCall(body, amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a message to a buyer to provide details about warranty information on a purchase in their order. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header contains the usage plan rate limits for the operation, when available. The preceding table
     * contains the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput might have higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return CreateWarrantyResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateWarrantyResponse createWarranty(
            CreateWarrantyRequest body, String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<CreateWarrantyResponse> resp =
                createWarrantyWithHttpInfo(body, amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a message to a buyer to provide details about warranty information on a purchase in their order. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header contains the usage plan rate limits for the operation, when available. The preceding table
     * contains the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput might have higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return CreateWarrantyResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public CreateWarrantyResponse createWarranty(
            CreateWarrantyRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<CreateWarrantyResponse> resp =
                createWarrantyWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a message to a buyer to provide details about warranty information on a purchase in their order. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header contains the usage plan rate limits for the operation, when available. The preceding table
     * contains the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput might have higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;CreateWarrantyResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateWarrantyResponse> createWarrantyWithHttpInfo(
            CreateWarrantyRequest body, String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = createWarrantyValidateBeforeCall(body, amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-createWarranty");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createWarrantyBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateWarrantyResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("createWarranty operation exceeds rate limit");
    }

    /**
     * Sends a message to a buyer to provide details about warranty information on a purchase in their order. **Usage
     * Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60;
     * response header contains the usage plan rate limits for the operation, when available. The preceding table
     * contains the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput might have higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;CreateWarrantyResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<CreateWarrantyResponse> createWarrantyWithHttpInfo(
            CreateWarrantyRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        return createWarrantyWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a message to a buyer to provide details about warranty information on a purchase in their
     * order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createWarrantyAsync(
            CreateWarrantyRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateWarrantyResponse> callback)
            throws ApiException, LWAException {
        return createWarrantyAsync(body, amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a message to a buyer to provide details about warranty information on a purchase in their
     * order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when
     * available. The preceding table contains the default rate and burst values for this operation. Selling partners
     * whose business demands require higher throughput might have higher rate and burst values than those shown here.
     * For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call createWarrantyAsync(
            CreateWarrantyRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<CreateWarrantyResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call =
                createWarrantyValidateBeforeCall(body, amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-createWarranty");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || createWarrantyBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<CreateWarrantyResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("createWarranty operation exceeds rate limit");
    }
    /**
     * Build call for getAttributes
     *
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call getAttributesCall(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/attributes"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {};

        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "GET",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call getAttributesValidateBeforeCall(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException("Missing the required parameter 'amazonOrderId' when calling getAttributes(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException("Missing the required parameter 'marketplaceIds' when calling getAttributes(Async)");
        }

        return getAttributesCall(amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Returns a response containing attributes related to an order. This includes buyer preferences. **Usage Plan:** |
     * Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |
     *
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return GetAttributesResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public GetAttributesResponse getAttributes(
            String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<GetAttributesResponse> resp =
                getAttributesWithHttpInfo(amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Returns a response containing attributes related to an order. This includes buyer preferences. **Usage Plan:** |
     * Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |
     *
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return GetAttributesResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public GetAttributesResponse getAttributes(String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<GetAttributesResponse> resp = getAttributesWithHttpInfo(amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Returns a response containing attributes related to an order. This includes buyer preferences. **Usage Plan:** |
     * Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |
     *
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;GetAttributesResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<GetAttributesResponse> getAttributesWithHttpInfo(
            String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = getAttributesValidateBeforeCall(amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-getAttributes");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || getAttributesBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<GetAttributesResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("getAttributes operation exceeds rate limit");
    }

    /**
     * Returns a response containing attributes related to an order. This includes buyer preferences. **Usage Plan:** |
     * Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |
     *
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;GetAttributesResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<GetAttributesResponse> getAttributesWithHttpInfo(
            String amazonOrderId, List<String> marketplaceIds) throws ApiException, LWAException {
        return getAttributesWithHttpInfo(amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Returns a response containing attributes related to an order. This includes buyer preferences.
     * **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |
     *
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call getAttributesAsync(
            String amazonOrderId, List<String> marketplaceIds, final ApiCallback<GetAttributesResponse> callback)
            throws ApiException, LWAException {
        return getAttributesAsync(amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Returns a response containing attributes related to an order. This includes buyer preferences.
     * **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |
     *
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call getAttributesAsync(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<GetAttributesResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = getAttributesValidateBeforeCall(amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-getAttributes");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || getAttributesBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<GetAttributesResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("getAttributes operation exceeds rate limit");
    }
    /**
     * Build call for getMessagingActionsForOrder
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     message types. (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call getMessagingActionsForOrderCall(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {};

        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "GET",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call getMessagingActionsForOrderValidateBeforeCall(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException(
                    "Missing the required parameter 'amazonOrderId' when calling getMessagingActionsForOrder(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling getMessagingActionsForOrder(Async)");
        }

        return getMessagingActionsForOrderCall(amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Returns a list of message types that are available for an order that you specify. A message type is represented
     * by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to call
     * an operation that sends a message. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5
     * | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation,
     * when available. The preceding table contains the default rate and burst values for this operation. Selling
     * partners whose business demands require higher throughput might have higher rate and burst values than those
     * shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     message types. (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return GetMessagingActionsForOrderResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public GetMessagingActionsForOrderResponse getMessagingActionsForOrder(
            String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<GetMessagingActionsForOrderResponse> resp =
                getMessagingActionsForOrderWithHttpInfo(amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Returns a list of message types that are available for an order that you specify. A message type is represented
     * by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to call
     * an operation that sends a message. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5
     * | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation,
     * when available. The preceding table contains the default rate and burst values for this operation. Selling
     * partners whose business demands require higher throughput might have higher rate and burst values than those
     * shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     message types. (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return GetMessagingActionsForOrderResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public GetMessagingActionsForOrderResponse getMessagingActionsForOrder(
            String amazonOrderId, List<String> marketplaceIds) throws ApiException, LWAException {
        ApiResponse<GetMessagingActionsForOrderResponse> resp =
                getMessagingActionsForOrderWithHttpInfo(amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Returns a list of message types that are available for an order that you specify. A message type is represented
     * by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to call
     * an operation that sends a message. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5
     * | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation,
     * when available. The preceding table contains the default rate and burst values for this operation. Selling
     * partners whose business demands require higher throughput might have higher rate and burst values than those
     * shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     message types. (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;GetMessagingActionsForOrderResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<GetMessagingActionsForOrderResponse> getMessagingActionsForOrderWithHttpInfo(
            String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = getMessagingActionsForOrderValidateBeforeCall(amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-getMessagingActionsForOrder");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || getMessagingActionsForOrderBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<GetMessagingActionsForOrderResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("getMessagingActionsForOrder operation exceeds rate limit");
    }

    /**
     * Returns a list of message types that are available for an order that you specify. A message type is represented
     * by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to call
     * an operation that sends a message. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5
     * | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation,
     * when available. The preceding table contains the default rate and burst values for this operation. Selling
     * partners whose business demands require higher throughput might have higher rate and burst values than those
     * shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     message types. (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;GetMessagingActionsForOrderResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<GetMessagingActionsForOrderResponse> getMessagingActionsForOrderWithHttpInfo(
            String amazonOrderId, List<String> marketplaceIds) throws ApiException, LWAException {
        return getMessagingActionsForOrderWithHttpInfo(amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Returns a list of message types that are available for an order that you specify. A message type
     * is represented by an actions object, which contains a path and query parameter(s). You can use the path and
     * parameter(s) to call an operation that sends a message. **Usage Plan:** | Rate (requests per second) | Burst | |
     * ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate
     * limits for the operation, when available. The preceding table contains the default rate and burst values for this
     * operation. Selling partners whose business demands require higher throughput might have higher rate and burst
     * values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     message types. (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call getMessagingActionsForOrderAsync(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<GetMessagingActionsForOrderResponse> callback)
            throws ApiException, LWAException {
        return getMessagingActionsForOrderAsync(amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Returns a list of message types that are available for an order that you specify. A message type
     * is represented by an actions object, which contains a path and query parameter(s). You can use the path and
     * parameter(s) to call an operation that sends a message. **Usage Plan:** | Rate (requests per second) | Burst | |
     * ---- | ---- | | 1 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate
     * limits for the operation, when available. The preceding table contains the default rate and burst values for this
     * operation. Selling partners whose business demands require higher throughput might have higher rate and burst
     * values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available
     *     message types. (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call getMessagingActionsForOrderAsync(
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<GetMessagingActionsForOrderResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call =
                getMessagingActionsForOrderValidateBeforeCall(amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(
                    request, restrictedDataToken, "MessagingApi-getMessagingActionsForOrder");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || getMessagingActionsForOrderBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<GetMessagingActionsForOrderResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("getMessagingActionsForOrder operation exceeds rate limit");
    }
    /**
     * Build call for sendInvoice
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call sendInvoiceCall(
            InvoiceRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/messaging/v1/orders/{amazonOrderId}/messages/invoice"
                .replaceAll("\\{" + "amazonOrderId" + "\\}", apiClient.escapeString(amazonOrderId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/hal+json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "POST",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call sendInvoiceValidateBeforeCall(
            InvoiceRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException("Missing the required parameter 'body' when calling sendInvoice(Async)");
        }
        // verify the required parameter 'amazonOrderId' is set
        if (amazonOrderId == null) {
            throw new ApiException("Missing the required parameter 'amazonOrderId' when calling sendInvoice(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException("Missing the required parameter 'marketplaceIds' when calling sendInvoice(Async)");
        }

        return sendInvoiceCall(body, amazonOrderId, marketplaceIds, progressRequestListener);
    }

    /**
     * Sends a message providing the buyer an invoice
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return InvoiceResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public InvoiceResponse sendInvoice(
            InvoiceRequest body, String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<InvoiceResponse> resp =
                sendInvoiceWithHttpInfo(body, amazonOrderId, marketplaceIds, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Sends a message providing the buyer an invoice
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return InvoiceResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public InvoiceResponse sendInvoice(InvoiceRequest body, String amazonOrderId, List<String> marketplaceIds)
            throws ApiException, LWAException {
        ApiResponse<InvoiceResponse> resp = sendInvoiceWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
        return resp.getData();
    }

    /**
     * Sends a message providing the buyer an invoice
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;InvoiceResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<InvoiceResponse> sendInvoiceWithHttpInfo(
            InvoiceRequest body, String amazonOrderId, List<String> marketplaceIds, String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = sendInvoiceValidateBeforeCall(body, amazonOrderId, marketplaceIds, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-sendInvoice");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || sendInvoiceBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<InvoiceResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("sendInvoice operation exceeds rate limit");
    }

    /**
     * Sends a message providing the buyer an invoice
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @return ApiResponse&lt;InvoiceResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<InvoiceResponse> sendInvoiceWithHttpInfo(
            InvoiceRequest body, String amazonOrderId, List<String> marketplaceIds) throws ApiException, LWAException {
        return sendInvoiceWithHttpInfo(body, amazonOrderId, marketplaceIds, null);
    }

    /**
     * (asynchronously) Sends a message providing the buyer an invoice
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call sendInvoiceAsync(
            InvoiceRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<InvoiceResponse> callback)
            throws ApiException, LWAException {
        return sendInvoiceAsync(body, amazonOrderId, marketplaceIds, callback, null);
    }
    /**
     * (asynchronously) Sends a message providing the buyer an invoice
     *
     * @param body This contains the message body for a message. (required)
     * @param amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     *     (required)
     * @param marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed.
     *     You can only specify one marketplace. (required)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call sendInvoiceAsync(
            InvoiceRequest body,
            String amazonOrderId,
            List<String> marketplaceIds,
            final ApiCallback<InvoiceResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = sendInvoiceValidateBeforeCall(body, amazonOrderId, marketplaceIds, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "MessagingApi-sendInvoice");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || sendInvoiceBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<InvoiceResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("sendInvoice operation exceeds rate limit");
    }

    public static class Builder {
        private LWAAuthorizationCredentials lwaAuthorizationCredentials;
        private String endpoint;
        private LWAAccessTokenCache lwaAccessTokenCache;
        private Boolean disableAccessTokenCache = false;
        private Boolean disableRateLimiting = false;

        public Builder lwaAuthorizationCredentials(LWAAuthorizationCredentials lwaAuthorizationCredentials) {
            this.lwaAuthorizationCredentials = lwaAuthorizationCredentials;
            return this;
        }

        public Builder endpoint(String endpoint) {
            this.endpoint = endpoint;
            return this;
        }

        public Builder lwaAccessTokenCache(LWAAccessTokenCache lwaAccessTokenCache) {
            this.lwaAccessTokenCache = lwaAccessTokenCache;
            return this;
        }

        public Builder disableAccessTokenCache() {
            this.disableAccessTokenCache = true;
            return this;
        }

        public Builder disableRateLimiting() {
            this.disableRateLimiting = true;
            return this;
        }

        public MessagingApi build() {
            if (lwaAuthorizationCredentials == null) {
                throw new RuntimeException("LWAAuthorizationCredentials not set");
            }

            if (StringUtil.isEmpty(endpoint)) {
                throw new RuntimeException("Endpoint not set");
            }

            LWAAuthorizationSigner lwaAuthorizationSigner = null;
            if (disableAccessTokenCache) {
                lwaAuthorizationSigner = new LWAAuthorizationSigner(lwaAuthorizationCredentials);
            } else {
                if (lwaAccessTokenCache == null) {
                    lwaAccessTokenCache = new LWAAccessTokenCacheImpl();
                }
                lwaAuthorizationSigner = new LWAAuthorizationSigner(lwaAuthorizationCredentials, lwaAccessTokenCache);
            }

            return new MessagingApi(
                    new ApiClient()
                            .setLWAAuthorizationSigner(lwaAuthorizationSigner)
                            .setBasePath(endpoint),
                    disableRateLimiting);
        }
    }
}
